home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WizardViewSubDbQueryWhere.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  3.7 KB  |  105 lines

  1. package asp.wizard;
  2.  
  3. import asp.wizard.util.UiUtil;
  4. import com.sun.java.swing.CellEditor;
  5. import com.sun.java.swing.JComboBox;
  6. import com.sun.java.swing.JTable;
  7. import com.sun.java.swing.table.DefaultTableModel;
  8. import java.awt.Component;
  9. import java.util.Vector;
  10.  
  11. public class WizardViewSubDbQueryWhere extends WizardViewAbstract {
  12.    private static WizardViewAbstract _instance = null;
  13.    private WVPanelDbQueryWhere _mainPanel;
  14.  
  15.    protected void addRow() {
  16.       this.cancelTableCellEditing();
  17.       Vector tableRow = new Vector();
  18.       tableRow.setSize(5);
  19.       this._mainPanel._tbmCriteria.addRow(tableRow);
  20.    }
  21.  
  22.    protected void deleteRow() {
  23.       this.cancelTableCellEditing();
  24.       DefaultTableModel tableModel = this._mainPanel._tbmCriteria;
  25.       JTable table = this._mainPanel._tblCriteria;
  26.       int[] selRows = table.getSelectedRows();
  27.       int delRowCount = selRows.length;
  28.       boolean delAll = delRowCount == table.getRowCount();
  29.  
  30.       for(int i = 0; i < delRowCount; ++i) {
  31.          if (i == delRowCount - 1 && delAll) {
  32.             for(int j = 0; j < tableModel.getColumnCount(); ++j) {
  33.                tableModel.setValueAt((Object)null, selRows[i] - i, j);
  34.             }
  35.          } else {
  36.             tableModel.removeRow(selRows[i] - i);
  37.          }
  38.       }
  39.  
  40.       if (delRowCount > 0) {
  41.          ((Component)table).repaint();
  42.          table.setRowSelectionInterval(selRows[0] - 1, selRows[0] - 1);
  43.       }
  44.  
  45.    }
  46.  
  47.    public DefaultTableModel getWhereData() {
  48.       return this._mainPanel._tbmCriteria;
  49.    }
  50.  
  51.    public static WizardViewAbstract getInstance() {
  52.       if (_instance == null) {
  53.          _instance = new WizardViewSubDbQueryWhere();
  54.       }
  55.  
  56.       return _instance;
  57.    }
  58.  
  59.    private void cancelTableCellEditing() {
  60.       CellEditor cellEditor = this._mainPanel._tblCriteria.getCellEditor();
  61.       if (cellEditor != null) {
  62.          cellEditor.cancelCellEditing();
  63.       }
  64.  
  65.    }
  66.  
  67.    protected void createMainPanel() {
  68.       this._mainPanel = new WVPanelDbQueryWhere();
  69.       this._mainPanel._btnAdd.addActionListener(new 1(this));
  70.       this._mainPanel._btnDelete.addActionListener(new 2(this));
  71.    }
  72.  
  73.    public WVPanelBase getMainPanel() {
  74.       return this._mainPanel;
  75.    }
  76.  
  77.    public void setSuffixes(Vector values) {
  78.       UiUtil.populateCombo(this._mainPanel._cboCritSuffix, values);
  79.    }
  80.  
  81.    public void setOperators(Vector values) {
  82.       UiUtil.populateCombo(this._mainPanel._cboOperator, values);
  83.    }
  84.  
  85.    public void setPrefixes(Vector values) {
  86.       UiUtil.populateCombo(this._mainPanel._cboCritPrefix, values);
  87.    }
  88.  
  89.    public JComboBox getcboLhs() {
  90.       return this._mainPanel._cboLhs;
  91.    }
  92.  
  93.    public JComboBox getcboRhs() {
  94.       return this._mainPanel._cboRhs;
  95.    }
  96.  
  97.    public void commit() {
  98.       CellEditor cellEditor = this._mainPanel._tblCriteria.getCellEditor();
  99.       if (cellEditor != null) {
  100.          cellEditor.stopCellEditing();
  101.       }
  102.  
  103.    }
  104. }
  105.